Don't re-trigger twice Java validation when a Java file is saved.#500
Don't re-trigger twice Java validation when a Java file is saved.#500angelozerr wants to merge 1 commit into
Conversation
c1c1a36 to
9cf25a0
Compare
file is saved. Signed-off-by: azerr <azerr@redhat.com>
9cf25a0 to
ec88978
Compare
datho7561
left a comment
There was a problem hiding this comment.
This works great and the code changes look good. I'd like to hear from Roland as well, but I think it's a good idea to merge this.
Great! Thanks @datho7561 for your feedback. |
rgrunber
left a comment
There was a problem hiding this comment.
Definitely fixes the properties changed notifications. Just noticed one behaviour change we should be aware of. Is this ok ?
|
|
||
| // validate all opened java files which belong to a MicroProfile project | ||
| triggerValidationForAll(null); | ||
| // triggerValidationForAll(null); |
There was a problem hiding this comment.
I think this breaks the following behaviour. You have a Java source file that defines configuration properties used in the configuration file. If those are added/removed, it affects some diagnostics :
Without this change
Screencast.From.2025-05-16.12-36-34.mp4
With this change
Screencast.From.2025-05-16.12-43-30.mp4
The diagnostics will not update when saving the config file, but they do update when continuing to type in the source file, or re-opening it. Are we ok with that ?
vscode-java does have a setting that causes this exact behaviour by default (ie. don't update opened document diagnostics when another source file being modified affects it). Mainly for performance gains.
There was a problem hiding this comment.
I remember that I had the similar problem with IJ Quarkus.
I am pretty sure that if you save your application.properties a second time, it will work.
If it that it is because we load in cache properties (for checking validation on Java file) from the /target/application.properties and not from src/main/resources/application.properties.
I think we should load cache from src/main/resources/application.properties.
We will loose the computed variable from maven for instance declared in teh properties file, but I have never seen this usecase.
There was a problem hiding this comment.
Saving a second time will not fix this. Validation isn't triggered. You either need to type, or re-open the file.
There was a problem hiding this comment.
That's strange it is working for me?
There was a problem hiding this comment.
Are you making changes and then saving or just hitting "Save" on an unchanged file ? Making changes will update the diagnostics but saving doesn't. Where would the validation come from when triggerValidationForAll is removed from didSave above.
There was a problem hiding this comment.
Are you making changes and then saving or just hitting "Save" on an unchanged file ? Making changes will update the diagnostics but saving doesn't. Where would the validation come from when
triggerValidationForAllis removed fromdidSaveabove.
Type a space and szve it twice.
I need to investigate more a proper fix.
There was a problem hiding this comment.
Typing a space in the Java source file even without saving the file will update the diagnostics. Look at the video under "With this change" above! You can see just typing updates the diagnostics so that's fine. What I mean is that saving a file that has no changes doesn't update the diagnostics.
There was a problem hiding this comment.
Sorry I mean tyep a space and save application.properried and do that twice.
It should update java diagnostics correctly, right?
There was a problem hiding this comment.
You're right, it does work. Interesting.
Update: I mean for the first save, the MP LS responds with no diagnostics, but on the second save it returns the diagnostic(s). I guess it can't save + return the updates diagnostics at the same time ? I guess that's fine for now.
@angelozerr all that's left is to address my comment at #500 (review)
|
|
||
| // Exclude resources in the main output location (e.g.,/ProjectName/bin) | ||
| IPath outputLocation = javaProject.getOutputLocation(); | ||
| IPath outputFullPath = ResourcesPlugin.getWorkspace().getRoot().getFolder(outputLocation).getFullPath(); |
There was a problem hiding this comment.
This isn't the full path.
You could compute the path relative to the workspace, in which case I don't think you need outputFullPath. you can do outputLocation.isPrefixOf(resourcePath).
If you want the absolute path on the filesystem, why not do something like javaProject.getProject().getLocation().append(outputLocation) which should be the absolute path. I've seen it used in some other places.
|
I close this PR in favor of #546 |

Don't re-trigger twice Java validation when a Java file is saved.
This PR avoid sending (type=3 which means configFile changed)
which retriggers validation of Java files when a Java file is saved.
See redhat-developer/vscode-quarkus#1004 (comment)